\hypertarget{storage_8h}{\section{storage.\-h File Reference}
\label{storage_8h}\index{storage.\-h@{storage.\-h}}
}


This file defines the interface between the storage client and server.  


{\ttfamily \#include $<$stdint.\-h$>$}\\*
\subsection*{Classes}
\begin{DoxyCompactItemize}
\item 
struct \hyperlink{structstorage__record}{storage\-\_\-record}
\begin{DoxyCompactList}\small\item\em Encapsulate the value associated with a key in a table. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Macros}
\begin{DoxyCompactItemize}
\item 
\hypertarget{storage_8h_a7186273cd88640b740b6333cd98ae243}{\#define \hyperlink{storage_8h_a7186273cd88640b740b6333cd98ae243}{M\-A\-X\-\_\-\-C\-O\-N\-F\-I\-G\-\_\-\-L\-I\-N\-E\-\_\-\-L\-E\-N}~1024}\label{storage_8h_a7186273cd88640b740b6333cd98ae243}

\begin{DoxyCompactList}\small\item\em Max characters in each config file line. \end{DoxyCompactList}\item 
\hypertarget{storage_8h_a6c4647395896246d6710ba980c31666c}{\#define \hyperlink{storage_8h_a6c4647395896246d6710ba980c31666c}{M\-A\-X\-\_\-\-U\-S\-E\-R\-N\-A\-M\-E\-\_\-\-L\-E\-N}~64}\label{storage_8h_a6c4647395896246d6710ba980c31666c}

\begin{DoxyCompactList}\small\item\em Max characters of server username. \end{DoxyCompactList}\item 
\hypertarget{storage_8h_aa13f93b74a500b0fd36cf2fd2fa5f30b}{\#define \hyperlink{storage_8h_aa13f93b74a500b0fd36cf2fd2fa5f30b}{M\-A\-X\-\_\-\-E\-N\-C\-\_\-\-P\-A\-S\-S\-W\-O\-R\-D\-\_\-\-L\-E\-N}~64}\label{storage_8h_aa13f93b74a500b0fd36cf2fd2fa5f30b}

\begin{DoxyCompactList}\small\item\em Max characters of server's encrypted password. \end{DoxyCompactList}\item 
\hypertarget{storage_8h_aa746ad89d7f59a152f37e3529057bd58}{\#define \hyperlink{storage_8h_aa746ad89d7f59a152f37e3529057bd58}{M\-A\-X\-\_\-\-H\-O\-S\-T\-\_\-\-L\-E\-N}~64}\label{storage_8h_aa746ad89d7f59a152f37e3529057bd58}

\begin{DoxyCompactList}\small\item\em Max characters of server hostname. \end{DoxyCompactList}\item 
\hypertarget{storage_8h_a374d6c9cec689b490a1c753145379723}{\#define \hyperlink{storage_8h_a374d6c9cec689b490a1c753145379723}{M\-A\-X\-\_\-\-P\-O\-R\-T\-\_\-\-L\-E\-N}~8}\label{storage_8h_a374d6c9cec689b490a1c753145379723}

\begin{DoxyCompactList}\small\item\em Max characters of server port. \end{DoxyCompactList}\item 
\hypertarget{storage_8h_abdd33f362ae3bbdacb5de76473aa8a2f}{\#define \hyperlink{storage_8h_abdd33f362ae3bbdacb5de76473aa8a2f}{M\-A\-X\-\_\-\-P\-A\-T\-H\-\_\-\-L\-E\-N}~256}\label{storage_8h_abdd33f362ae3bbdacb5de76473aa8a2f}

\begin{DoxyCompactList}\small\item\em Max characters of data directory path. \end{DoxyCompactList}\item 
\hypertarget{storage_8h_a6f4cdd0162e9f2ab251fa5b23410c8da}{\#define \hyperlink{storage_8h_a6f4cdd0162e9f2ab251fa5b23410c8da}{M\-A\-X\-\_\-\-T\-A\-B\-L\-E\-S}~100}\label{storage_8h_a6f4cdd0162e9f2ab251fa5b23410c8da}

\begin{DoxyCompactList}\small\item\em Max tables supported by the server. \end{DoxyCompactList}\item 
\hypertarget{storage_8h_ad02d7128cbc04a5ec5ee79c6beb66730}{\#define \hyperlink{storage_8h_ad02d7128cbc04a5ec5ee79c6beb66730}{M\-A\-X\-\_\-\-R\-E\-C\-O\-R\-D\-S\-\_\-\-P\-E\-R\-\_\-\-T\-A\-B\-L\-E}~1000}\label{storage_8h_ad02d7128cbc04a5ec5ee79c6beb66730}

\begin{DoxyCompactList}\small\item\em Max records per table. \end{DoxyCompactList}\item 
\hypertarget{storage_8h_ae7854bc280576d57ec5c80995d5ea94c}{\#define \hyperlink{storage_8h_ae7854bc280576d57ec5c80995d5ea94c}{M\-A\-X\-\_\-\-T\-A\-B\-L\-E\-\_\-\-L\-E\-N}~20}\label{storage_8h_ae7854bc280576d57ec5c80995d5ea94c}

\begin{DoxyCompactList}\small\item\em Max characters of a table name. \end{DoxyCompactList}\item 
\hypertarget{storage_8h_ad91bfaf106e42aa552f1605c5b8a9ef2}{\#define \hyperlink{storage_8h_ad91bfaf106e42aa552f1605c5b8a9ef2}{M\-A\-X\-\_\-\-K\-E\-Y\-\_\-\-L\-E\-N}~20}\label{storage_8h_ad91bfaf106e42aa552f1605c5b8a9ef2}

\begin{DoxyCompactList}\small\item\em Max characters of a key name. \end{DoxyCompactList}\item 
\hypertarget{storage_8h_a053b7859476cc9867ec62c49e68d3fa1}{\#define \hyperlink{storage_8h_a053b7859476cc9867ec62c49e68d3fa1}{M\-A\-X\-\_\-\-C\-O\-N\-N\-E\-C\-T\-I\-O\-N\-S}~10}\label{storage_8h_a053b7859476cc9867ec62c49e68d3fa1}

\begin{DoxyCompactList}\small\item\em Max simultaneous client connections. \end{DoxyCompactList}\item 
\hypertarget{storage_8h_a2c806bc7de304d1d07bb12c9d58dbdd1}{\#define \hyperlink{storage_8h_a2c806bc7de304d1d07bb12c9d58dbdd1}{M\-A\-X\-\_\-\-C\-O\-L\-U\-M\-N\-S\-\_\-\-P\-E\-R\-\_\-\-T\-A\-B\-L\-E}~10}\label{storage_8h_a2c806bc7de304d1d07bb12c9d58dbdd1}

\begin{DoxyCompactList}\small\item\em Max columns per table. \end{DoxyCompactList}\item 
\hypertarget{storage_8h_a5cced553ee7679aebe25952d79c7b86b}{\#define \hyperlink{storage_8h_a5cced553ee7679aebe25952d79c7b86b}{M\-A\-X\-\_\-\-C\-O\-L\-N\-A\-M\-E\-\_\-\-L\-E\-N}~20}\label{storage_8h_a5cced553ee7679aebe25952d79c7b86b}

\begin{DoxyCompactList}\small\item\em Max characters of a column name. \end{DoxyCompactList}\item 
\hypertarget{storage_8h_ab9cbe6531d78ffac767508924ec1b5ac}{\#define \hyperlink{storage_8h_ab9cbe6531d78ffac767508924ec1b5ac}{M\-A\-X\-\_\-\-S\-T\-R\-T\-Y\-P\-E\-\_\-\-S\-I\-Z\-E}~40}\label{storage_8h_ab9cbe6531d78ffac767508924ec1b5ac}

\begin{DoxyCompactList}\small\item\em Max S\-I\-Z\-E of string types. \end{DoxyCompactList}\item 
\hypertarget{storage_8h_a00a29850f2b5b985f776f864d83e5ac3}{\#define \hyperlink{storage_8h_a00a29850f2b5b985f776f864d83e5ac3}{M\-A\-X\-\_\-\-V\-A\-L\-U\-E\-\_\-\-L\-E\-N}~800}\label{storage_8h_a00a29850f2b5b985f776f864d83e5ac3}

\begin{DoxyCompactList}\small\item\em Max characters of a value. \end{DoxyCompactList}\item 
\hypertarget{storage_8h_ad633b9edd00d2bf59ace1af24cc483f4}{\#define \hyperlink{storage_8h_ad633b9edd00d2bf59ace1af24cc483f4}{E\-R\-R\-\_\-\-I\-N\-V\-A\-L\-I\-D\-\_\-\-P\-A\-R\-A\-M}~1}\label{storage_8h_ad633b9edd00d2bf59ace1af24cc483f4}

\begin{DoxyCompactList}\small\item\em A parameter is not valid. \end{DoxyCompactList}\item 
\hypertarget{storage_8h_aeef6b01ffc4d49ae7b4a2e17eefb4ade}{\#define \hyperlink{storage_8h_aeef6b01ffc4d49ae7b4a2e17eefb4ade}{E\-R\-R\-\_\-\-C\-O\-N\-N\-E\-C\-T\-I\-O\-N\-\_\-\-F\-A\-I\-L}~2}\label{storage_8h_aeef6b01ffc4d49ae7b4a2e17eefb4ade}

\begin{DoxyCompactList}\small\item\em Error connecting to server. \end{DoxyCompactList}\item 
\hypertarget{storage_8h_ab03e83c2f65be8b009eff331f370058d}{\#define \hyperlink{storage_8h_ab03e83c2f65be8b009eff331f370058d}{E\-R\-R\-\_\-\-N\-O\-T\-\_\-\-A\-U\-T\-H\-E\-N\-T\-I\-C\-A\-T\-E\-D}~3}\label{storage_8h_ab03e83c2f65be8b009eff331f370058d}

\begin{DoxyCompactList}\small\item\em Client not authenticated. \end{DoxyCompactList}\item 
\hypertarget{storage_8h_a3ff770fb1d0d1d37b43e6a27f85a7cd1}{\#define \hyperlink{storage_8h_a3ff770fb1d0d1d37b43e6a27f85a7cd1}{E\-R\-R\-\_\-\-A\-U\-T\-H\-E\-N\-T\-I\-C\-A\-T\-I\-O\-N\-\_\-\-F\-A\-I\-L\-E\-D}~4}\label{storage_8h_a3ff770fb1d0d1d37b43e6a27f85a7cd1}

\begin{DoxyCompactList}\small\item\em Client authentication failed. \end{DoxyCompactList}\item 
\hypertarget{storage_8h_ab1c0830c9f58e53bf4a9ff593a24b761}{\#define \hyperlink{storage_8h_ab1c0830c9f58e53bf4a9ff593a24b761}{E\-R\-R\-\_\-\-T\-A\-B\-L\-E\-\_\-\-N\-O\-T\-\_\-\-F\-O\-U\-N\-D}~5}\label{storage_8h_ab1c0830c9f58e53bf4a9ff593a24b761}

\begin{DoxyCompactList}\small\item\em The table does not exist. \end{DoxyCompactList}\item 
\hypertarget{storage_8h_afd0cce588bf32d57085d8d0a28bd8e34}{\#define \hyperlink{storage_8h_afd0cce588bf32d57085d8d0a28bd8e34}{E\-R\-R\-\_\-\-K\-E\-Y\-\_\-\-N\-O\-T\-\_\-\-F\-O\-U\-N\-D}~6}\label{storage_8h_afd0cce588bf32d57085d8d0a28bd8e34}

\begin{DoxyCompactList}\small\item\em The key does not exist. \end{DoxyCompactList}\item 
\hypertarget{storage_8h_a60d04c865fd58d86758894edca38bf30}{\#define \hyperlink{storage_8h_a60d04c865fd58d86758894edca38bf30}{E\-R\-R\-\_\-\-U\-N\-K\-N\-O\-W\-N}~7}\label{storage_8h_a60d04c865fd58d86758894edca38bf30}

\begin{DoxyCompactList}\small\item\em Any other error. \end{DoxyCompactList}\item 
\hypertarget{storage_8h_a31edc5f52b2c941d356fda0e409272ef}{\#define \hyperlink{storage_8h_a31edc5f52b2c941d356fda0e409272ef}{E\-R\-R\-\_\-\-T\-R\-A\-N\-S\-A\-C\-T\-I\-O\-N\-\_\-\-A\-B\-O\-R\-T}~8}\label{storage_8h_a31edc5f52b2c941d356fda0e409272ef}

\begin{DoxyCompactList}\small\item\em Transaction abort error. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Functions}
\begin{DoxyCompactItemize}
\item 
void $\ast$ \hyperlink{storage_8h_abc3751ffba629aad5a4b8c7c22a75e11}{storage\-\_\-connect} (const char $\ast$hostname, const int port)
\begin{DoxyCompactList}\small\item\em Establish a connection to the server. \end{DoxyCompactList}\item 
int \hyperlink{storage_8h_aa97b5545b3eefb5055a4e6febd375796}{storage\-\_\-auth} (const char $\ast$username, const char $\ast$passwd, void $\ast$conn)
\begin{DoxyCompactList}\small\item\em Authenticate the client's connection to the server. \end{DoxyCompactList}\item 
int \hyperlink{storage_8h_ac75689ee50898a2f6580c6489e886b59}{storage\-\_\-get} (const char $\ast$\hyperlink{structtable}{table}, const char $\ast$key, struct \hyperlink{structstorage__record}{storage\-\_\-record} $\ast$record, void $\ast$conn)
\begin{DoxyCompactList}\small\item\em Retrieve the value associated with a key in a table. \end{DoxyCompactList}\item 
int \hyperlink{storage_8h_a8a42f72670cdcd7bf83416df1f1b090d}{storage\-\_\-set} (const char $\ast$\hyperlink{structtable}{table}, const char $\ast$key, struct \hyperlink{structstorage__record}{storage\-\_\-record} $\ast$record, void $\ast$conn)
\begin{DoxyCompactList}\small\item\em Store a key/value pair in a table. \end{DoxyCompactList}\item 
int \hyperlink{storage_8h_af4e09b41d2bc5b8c25936fe952e748b2}{storage\-\_\-query} (const char $\ast$\hyperlink{structtable}{table}, const char $\ast$predicates, char $\ast$$\ast$keys, const int max\-\_\-keys, void $\ast$conn)
\begin{DoxyCompactList}\small\item\em Query the table for records, and retrieve the matching keys. \end{DoxyCompactList}\item 
int \hyperlink{storage_8h_acd449536193542befbae2ff5e916f657}{storage\-\_\-disconnect} (void $\ast$conn)
\begin{DoxyCompactList}\small\item\em Close the connection to the server. \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Detailed Description}
This file defines the interface between the storage client and server. The functions here should be implemented in \hyperlink{storage_8c}{storage.\-c}.

{\bfseries You should not modify this file, or else the code used to mark your implementation will break.} 

Definition in file \hyperlink{storage_8h_source}{storage.\-h}.



\subsection{Function Documentation}
\hypertarget{storage_8h_aa97b5545b3eefb5055a4e6febd375796}{\index{storage.\-h@{storage.\-h}!storage\-\_\-auth@{storage\-\_\-auth}}
\index{storage\-\_\-auth@{storage\-\_\-auth}!storage.h@{storage.\-h}}
\subsubsection[{storage\-\_\-auth}]{\setlength{\rightskip}{0pt plus 5cm}int storage\-\_\-auth (
\begin{DoxyParamCaption}
\item[{const char $\ast$}]{username, }
\item[{const char $\ast$}]{passwd, }
\item[{void $\ast$}]{conn}
\end{DoxyParamCaption}
)}}\label{storage_8h_aa97b5545b3eefb5055a4e6febd375796}


Authenticate the client's connection to the server. 


\begin{DoxyParams}{Parameters}
{\em username} & Username to access the storage server. \\
\hline
{\em passwd} & Password in its plain text form. \\
\hline
{\em conn} & A connection to the server. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
Return 0 if successful, and -\/1 otherwise.
\end{DoxyReturn}
On error, errno will be set to E\-R\-R\-\_\-\-A\-U\-T\-H\-E\-N\-T\-I\-C\-A\-T\-I\-O\-N\-\_\-\-F\-A\-I\-L\-E\-D.

This function autheticates a connection to socket and prints to socketfd what has been authenticated \begin{DoxyReturn}{Returns}
0 if successful, otherwise, returns -\/1 
\end{DoxyReturn}


Definition at line 164 of file storage.\-c.



References authen, connected, E\-R\-R\-\_\-\-A\-U\-T\-H\-E\-N\-T\-I\-C\-A\-T\-I\-O\-N\-\_\-\-F\-A\-I\-L\-E\-D, E\-R\-R\-\_\-\-C\-O\-N\-N\-E\-C\-T\-I\-O\-N\-\_\-\-F\-A\-I\-L, E\-R\-R\-\_\-\-I\-N\-V\-A\-L\-I\-D\-\_\-\-P\-A\-R\-A\-M, generate\-\_\-encrypted\-\_\-password(), logger(), M\-A\-X\-\_\-\-C\-M\-D\-\_\-\-L\-E\-N, M\-A\-X\-\_\-\-E\-N\-C\-\_\-\-P\-A\-S\-S\-W\-O\-R\-D\-\_\-\-L\-E\-N, M\-A\-X\-\_\-\-H\-O\-S\-T\-\_\-\-L\-E\-N, M\-A\-X\-\_\-\-U\-S\-E\-R\-N\-A\-M\-E\-\_\-\-L\-E\-N, recvline(), and sendall().



Referenced by main().

\hypertarget{storage_8h_abc3751ffba629aad5a4b8c7c22a75e11}{\index{storage.\-h@{storage.\-h}!storage\-\_\-connect@{storage\-\_\-connect}}
\index{storage\-\_\-connect@{storage\-\_\-connect}!storage.h@{storage.\-h}}
\subsubsection[{storage\-\_\-connect}]{\setlength{\rightskip}{0pt plus 5cm}void$\ast$ storage\-\_\-connect (
\begin{DoxyParamCaption}
\item[{const char $\ast$}]{hostname, }
\item[{const int}]{port}
\end{DoxyParamCaption}
)}}\label{storage_8h_abc3751ffba629aad5a4b8c7c22a75e11}


Establish a connection to the server. 


\begin{DoxyParams}{Parameters}
{\em hostname} & The I\-P address or hostname of the server. \\
\hline
{\em port} & The T\-C\-P port of the server. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
If successful, return a pointer to a data structure that represents a connection to the server. Otherwise return N\-U\-L\-L.
\end{DoxyReturn}
On error, errno will be set to one of the following, as appropriate\-: E\-R\-R\-\_\-\-I\-N\-V\-A\-L\-I\-D\-\_\-\-P\-A\-R\-A\-M, E\-R\-R\-\_\-\-C\-O\-N\-N\-E\-C\-T\-I\-O\-N\-\_\-\-F\-A\-I\-L, or E\-R\-R\-\_\-\-U\-N\-K\-N\-O\-W\-N.

This function connects to a port with hostname 
\begin{DoxyParams}{Parameters}
{\em hostname} & localhost \\
\hline
{\em port} & A port number \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
N\-U\-L\-L if unsuccessful 
\end{DoxyReturn}


Definition at line 41 of file storage.\-c.



References connected, E\-R\-R\-\_\-\-C\-O\-N\-N\-E\-C\-T\-I\-O\-N\-\_\-\-F\-A\-I\-L, E\-R\-R\-\_\-\-I\-N\-V\-A\-L\-I\-D\-\_\-\-P\-A\-R\-A\-M, logger(), M\-A\-X\-\_\-\-H\-O\-S\-T\-\_\-\-L\-E\-N, M\-A\-X\-\_\-\-P\-O\-R\-T\-\_\-\-L\-E\-N, and num\-Digits().



Referenced by main().

\hypertarget{storage_8h_acd449536193542befbae2ff5e916f657}{\index{storage.\-h@{storage.\-h}!storage\-\_\-disconnect@{storage\-\_\-disconnect}}
\index{storage\-\_\-disconnect@{storage\-\_\-disconnect}!storage.h@{storage.\-h}}
\subsubsection[{storage\-\_\-disconnect}]{\setlength{\rightskip}{0pt plus 5cm}int storage\-\_\-disconnect (
\begin{DoxyParamCaption}
\item[{void $\ast$}]{conn}
\end{DoxyParamCaption}
)}}\label{storage_8h_acd449536193542befbae2ff5e916f657}


Close the connection to the server. 


\begin{DoxyParams}{Parameters}
{\em conn} & A pointer to the connection structure returned in an earlier call to \hyperlink{storage_8c_abc3751ffba629aad5a4b8c7c22a75e11}{storage\-\_\-connect()}. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
Return 0 if successful, and -\/1 otherwise.
\end{DoxyReturn}
On error, errno will be set to one of the following, as appropriate\-: E\-R\-R\-\_\-\-I\-N\-V\-A\-L\-I\-D\-\_\-\-P\-A\-R\-A\-M, E\-R\-R\-\_\-\-C\-O\-N\-N\-E\-C\-T\-I\-O\-N\-\_\-\-F\-A\-I\-L, or E\-R\-R\-\_\-\-U\-N\-K\-N\-O\-W\-N.

This function disconnects a given sockfd 
\begin{DoxyParams}{Parameters}
{\em conn} & The sockfd to be disconnected \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
returns 0 if successful, otherwise, returns -\/1 
\end{DoxyReturn}


Definition at line 574 of file storage.\-c.



References authen, connected, E\-R\-R\-\_\-\-I\-N\-V\-A\-L\-I\-D\-\_\-\-P\-A\-R\-A\-M, E\-R\-R\-\_\-\-U\-N\-K\-N\-O\-W\-N, and logger().



Referenced by main().

\hypertarget{storage_8h_ac75689ee50898a2f6580c6489e886b59}{\index{storage.\-h@{storage.\-h}!storage\-\_\-get@{storage\-\_\-get}}
\index{storage\-\_\-get@{storage\-\_\-get}!storage.h@{storage.\-h}}
\subsubsection[{storage\-\_\-get}]{\setlength{\rightskip}{0pt plus 5cm}int storage\-\_\-get (
\begin{DoxyParamCaption}
\item[{const char $\ast$}]{table, }
\item[{const char $\ast$}]{key, }
\item[{struct {\bf storage\-\_\-record} $\ast$}]{record, }
\item[{void $\ast$}]{conn}
\end{DoxyParamCaption}
)}}\label{storage_8h_ac75689ee50898a2f6580c6489e886b59}


Retrieve the value associated with a key in a table. 


\begin{DoxyParams}{Parameters}
{\em table} & A table in the database. \\
\hline
{\em key} & A key in the table. \\
\hline
{\em record} & A pointer to a record struture. \\
\hline
{\em conn} & A connection to the server. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
Return 0 if successful, and -\/1 otherwise.
\end{DoxyReturn}
On error, errno will be set to one of the following, as appropriate\-: E\-R\-R\-\_\-\-I\-N\-V\-A\-L\-I\-D\-\_\-\-P\-A\-R\-A\-M, E\-R\-R\-\_\-\-C\-O\-N\-N\-E\-C\-T\-I\-O\-N\-\_\-\-F\-A\-I\-L, E\-R\-R\-\_\-\-T\-A\-B\-L\-E\-\_\-\-N\-O\-T\-\_\-\-F\-O\-U\-N\-D, E\-R\-R\-\_\-\-K\-E\-Y\-\_\-\-N\-O\-T\-\_\-\-F\-O\-U\-N\-D, E\-R\-R\-\_\-\-N\-O\-T\-\_\-\-A\-U\-T\-H\-E\-N\-T\-I\-C\-A\-T\-E\-D, or E\-R\-R\-\_\-\-U\-N\-K\-N\-O\-W\-N.

The record with the specified key in the specified table is retrieved from the server using the specified connection. If the key is found, the record structure is populated with the details of the corresponding record. Otherwise, the record structure is not modified.

This function is used to get a record given a key and table It populates the record structure with info if found, otherwise, record is not modified 
\begin{DoxyParams}{Parameters}
{\em table} & containing key of interest \\
\hline
{\em key's} & value to be get \\
\hline
{\em record} & structure to store information of value gotten \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
returns 0 if successful, otherwise returns -\/1 
\end{DoxyReturn}


Definition at line 264 of file storage.\-c.



References authen, check\-Name(), connected, E\-R\-R\-\_\-\-C\-O\-N\-N\-E\-C\-T\-I\-O\-N\-\_\-\-F\-A\-I\-L, E\-R\-R\-\_\-\-I\-N\-V\-A\-L\-I\-D\-\_\-\-P\-A\-R\-A\-M, E\-R\-R\-\_\-\-K\-E\-Y\-\_\-\-N\-O\-T\-\_\-\-F\-O\-U\-N\-D, E\-R\-R\-\_\-\-N\-O\-T\-\_\-\-A\-U\-T\-H\-E\-N\-T\-I\-C\-A\-T\-E\-D, E\-R\-R\-\_\-\-T\-A\-B\-L\-E\-\_\-\-N\-O\-T\-\_\-\-F\-O\-U\-N\-D, get\-Arguments(), logger(), M\-A\-X\-\_\-\-C\-M\-D\-\_\-\-L\-E\-N, M\-A\-X\-\_\-\-K\-E\-Y\-\_\-\-L\-E\-N, M\-A\-X\-\_\-\-T\-A\-B\-L\-E\-\_\-\-L\-E\-N, recvline(), sendall(), and storage\-\_\-record\-::value.



Referenced by main().

\hypertarget{storage_8h_af4e09b41d2bc5b8c25936fe952e748b2}{\index{storage.\-h@{storage.\-h}!storage\-\_\-query@{storage\-\_\-query}}
\index{storage\-\_\-query@{storage\-\_\-query}!storage.h@{storage.\-h}}
\subsubsection[{storage\-\_\-query}]{\setlength{\rightskip}{0pt plus 5cm}int storage\-\_\-query (
\begin{DoxyParamCaption}
\item[{const char $\ast$}]{table, }
\item[{const char $\ast$}]{predicates, }
\item[{char $\ast$$\ast$}]{keys, }
\item[{const int}]{max\-\_\-keys, }
\item[{void $\ast$}]{conn}
\end{DoxyParamCaption}
)}}\label{storage_8h_af4e09b41d2bc5b8c25936fe952e748b2}


Query the table for records, and retrieve the matching keys. 


\begin{DoxyParams}{Parameters}
{\em table} & A table in the database. \\
\hline
{\em predicates} & A comma separated list of predicates. \\
\hline
{\em keys} & An array of strings where the keys whose records match the specified predicates will be copied. The array must have room for at least max\-\_\-keys elements. The caller must allocate memory for this array. \\
\hline
{\em max\-\_\-keys} & The size of the keys array. \\
\hline
{\em conn} & A connection to the server. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
Return the number of matching keys (which may be more than max\-\_\-keys) if successful, and -\/1 otherwise.
\end{DoxyReturn}
On error, errno will be set to one of the following, as appropriate\-: E\-R\-R\-\_\-\-I\-N\-V\-A\-L\-I\-D\-\_\-\-P\-A\-R\-A\-M, E\-R\-R\-\_\-\-C\-O\-N\-N\-E\-C\-T\-I\-O\-N\-\_\-\-F\-A\-I\-L, E\-R\-R\-\_\-\-T\-A\-B\-L\-E\-\_\-\-N\-O\-T\-\_\-\-F\-O\-U\-N\-D, E\-R\-R\-\_\-\-K\-E\-Y\-\_\-\-N\-O\-T\-\_\-\-F\-O\-U\-N\-D, E\-R\-R\-\_\-\-N\-O\-T\-\_\-\-A\-U\-T\-H\-E\-N\-T\-I\-C\-A\-T\-E\-D, or E\-R\-R\-\_\-\-U\-N\-K\-N\-O\-W\-N.

Each predicate consists of a column name, an operator, and a value, each separated by optional whitespace. The operator may be a \char`\"{}=\char`\"{} for string types, or one of \char`\"{}$<$, $>$, =\char`\"{} for int and float types. An example of query predicates is \char`\"{}name = bob, mark $>$ 90\char`\"{}. 

Definition at line 622 of file storage.\-c.



References authen, check\-Name(), connected, E\-R\-R\-\_\-\-C\-O\-N\-N\-E\-C\-T\-I\-O\-N\-\_\-\-F\-A\-I\-L, E\-R\-R\-\_\-\-I\-N\-V\-A\-L\-I\-D\-\_\-\-P\-A\-R\-A\-M, E\-R\-R\-\_\-\-N\-O\-T\-\_\-\-A\-U\-T\-H\-E\-N\-T\-I\-C\-A\-T\-E\-D, E\-R\-R\-\_\-\-T\-A\-B\-L\-E\-\_\-\-N\-O\-T\-\_\-\-F\-O\-U\-N\-D, logger(), M\-A\-X\-\_\-\-C\-M\-D\-\_\-\-L\-E\-N, M\-A\-X\-\_\-\-T\-A\-B\-L\-E\-\_\-\-L\-E\-N, recvline(), and sendall().



Referenced by main().

\hypertarget{storage_8h_a8a42f72670cdcd7bf83416df1f1b090d}{\index{storage.\-h@{storage.\-h}!storage\-\_\-set@{storage\-\_\-set}}
\index{storage\-\_\-set@{storage\-\_\-set}!storage.h@{storage.\-h}}
\subsubsection[{storage\-\_\-set}]{\setlength{\rightskip}{0pt plus 5cm}int storage\-\_\-set (
\begin{DoxyParamCaption}
\item[{const char $\ast$}]{table, }
\item[{const char $\ast$}]{key, }
\item[{struct {\bf storage\-\_\-record} $\ast$}]{record, }
\item[{void $\ast$}]{conn}
\end{DoxyParamCaption}
)}}\label{storage_8h_a8a42f72670cdcd7bf83416df1f1b090d}


Store a key/value pair in a table. 


\begin{DoxyParams}{Parameters}
{\em table} & A table in the database. \\
\hline
{\em key} & A key in the table. \\
\hline
{\em record} & A pointer to a record struture. \\
\hline
{\em conn} & A connection to the server. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
Return 0 if successful, and -\/1 otherwise.
\end{DoxyReturn}
On error, errno will be set to one of the following, as appropriate\-: E\-R\-R\-\_\-\-I\-N\-V\-A\-L\-I\-D\-\_\-\-P\-A\-R\-A\-M, E\-R\-R\-\_\-\-C\-O\-N\-N\-E\-C\-T\-I\-O\-N\-\_\-\-F\-A\-I\-L, E\-R\-R\-\_\-\-T\-A\-B\-L\-E\-\_\-\-N\-O\-T\-\_\-\-F\-O\-U\-N\-D, E\-R\-R\-\_\-\-K\-E\-Y\-\_\-\-N\-O\-T\-\_\-\-F\-O\-U\-N\-D, E\-R\-R\-\_\-\-N\-O\-T\-\_\-\-A\-U\-T\-H\-E\-N\-T\-I\-C\-A\-T\-E\-D, or E\-R\-R\-\_\-\-U\-N\-K\-N\-O\-W\-N.

The key and record are stored in the table of the database using the connection. If the key already exists in the table, the corresponding record is updated with the one specified here. If the key exists in the table and the record is N\-U\-L\-L, the key/value pair are deleted from the table.

This function sets a record given a key and table If key exist, record is update, If key exist, but record is N\-U\-L\-L, the key valued pair are deleted from table If key does not exist, will set errno = E\-R\-R\-\_\-\-K\-E\-Y\-\_\-\-N\-O\-T\-\_\-\-F\-O\-U\-N\-D If table does not exist, will set errno = E\-R\-R\-\_\-\-T\-A\-B\-L\-E\-\_\-\-N\-O\-T\-\_\-\-F\-O\-U\-N\-D 
\begin{DoxyParams}{Parameters}
{\em table} & which contains key \\
\hline
{\em key} & to be set \\
\hline
{\em record} & structure which contains the record to be set of key, may be N\-U\-L\-L for deletion \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 if successful, otherwise returns -\/1 
\end{DoxyReturn}


Definition at line 405 of file storage.\-c.



References authen, check\-Name(), check\-Value(), connected, E\-R\-R\-\_\-\-C\-O\-N\-N\-E\-C\-T\-I\-O\-N\-\_\-\-F\-A\-I\-L, E\-R\-R\-\_\-\-I\-N\-V\-A\-L\-I\-D\-\_\-\-P\-A\-R\-A\-M, E\-R\-R\-\_\-\-K\-E\-Y\-\_\-\-N\-O\-T\-\_\-\-F\-O\-U\-N\-D, E\-R\-R\-\_\-\-N\-O\-T\-\_\-\-A\-U\-T\-H\-E\-N\-T\-I\-C\-A\-T\-E\-D, E\-R\-R\-\_\-\-T\-A\-B\-L\-E\-\_\-\-N\-O\-T\-\_\-\-F\-O\-U\-N\-D, logger(), M\-A\-X\-\_\-\-C\-M\-D\-\_\-\-L\-E\-N, M\-A\-X\-\_\-\-K\-E\-Y\-\_\-\-L\-E\-N, M\-A\-X\-\_\-\-T\-A\-B\-L\-E\-\_\-\-L\-E\-N, M\-A\-X\-\_\-\-V\-A\-L\-U\-E\-\_\-\-L\-E\-N, recvline(), sendall(), and storage\-\_\-record\-::value.



Referenced by main().

